dojo.provide("miaigo.model.MoveValidator");

miaigo.model.MoveValidator.testPlace = function(baseState, moveParam)
{
    var stone = baseState.stoneAt({x: moveParam.x, y: moveParam.y});
    return (stone == null);
}

// Return Value:
// {
//   blackBlocks: [1, 3, 5],
//   whiteBlocks: [2]
// }
miaigo.model.MoveValidator.testCapture = function(boardState)
{
    var captured = {};
    captured.blackBlocks = new Array();
    captured.whiteBlocks = new Array();

    var blocks = boardState.getAllBlocks();

    for (var blockID = 0; blockID < blocks.length; blockID++)
    {
	if (blocks[blockID])
	{
	    var color = blocks[blockID].getColor();
	    var lives = boardState.getBlockLives(blockID);

	    if (!lives || lives.getAllPoints().length <= 0)
	    {
		if (color == "black")
		{
		    captured.blackBlocks.push(blockID);
		}
		else if (color == "white")
		{
		    captured.whiteBlocks.push(blockID);
		}
	    }
	}
    }

    return captured;
}